package fourth.jsp;

import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.PageContext;

public class JspUtils {
    /**
     *   在普通类中可以通过PageContext获取其它JSP隐式对象,具体如下
     *   getException方法返回exception隐式对象
     * getPage方法返回page隐式对象
     * getRequest方法返回request隐式对象
     * getResponse方法返回response隐式对象
     * getServletConfig方法返回config隐式对象
     * getServletContext方法返回application隐式对象
     * getSession方法返回session隐式对象
     * getOut方法返回out隐式对象
     */
    public static void main(String[] args) {

    }
    public void handleJSP(PageContext pageContext){
        ServletRequest request = pageContext.getRequest();
        ServletResponse response = pageContext.getResponse();
        HttpSession session = pageContext.getSession();
        ServletContext application = pageContext.getServletContext();

        pageContext.setAttribute("username", "xxxxxx");
        Object username = pageContext.getAttribute("username");
        pageContext.removeAttribute("username");
    }
}
